package com.smartstate.dataManagement.service.impl;

import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smartstate.dataManagement.dto.PageDTO;
import com.smartstate.dataManagement.entity.Rate;
import com.smartstate.dataManagement.entity.RateCalculation;
import com.smartstate.dataManagement.mapper.RateCalculationMapper;
import com.smartstate.dataManagement.mapper.RateMapper;
import com.smartstate.dataManagement.service.RateCalculationService;
import com.smartstate.dataManagement.service.RateService;
import com.smartstate.dataManagement.util.RateUtils;
import com.smartstate.dataManagement.vo.RateCalculationVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>费率</p>
 * <p>@Author 陈永杰</p>
 * <p>@Date: 2022/8/25</p>
 * <p>@Time: 16:53</p>
 * <p>@version 1.0 <p>
 */
@Service
public class RateImpl extends ServiceImpl<RateMapper, Rate> implements RateService {

    @Autowired
    private RateMapper rateMapper;


    /**
     * 获取费率所有信息分页
     *
     * @param
     * @return
     */
    @Override
    public Page<Rate> queryAllPageByDTO(PageDTO pageDTO) {
        Page objectPage = new Page(pageDTO.getPage(),pageDTO.getSize());
        LambdaQueryWrapper<Rate> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
        RateCalculationVo dto = (RateCalculationVo) pageDTO.getDto();
        String Id = dto.getId();
        if (!"".equals(Id)){
            objectLambdaQueryWrapper.eq(Rate::getId,Id);
        }
        return rateMapper.selectPage(objectPage,objectLambdaQueryWrapper);
    }


}